import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime

# 自定义打印
def print_log(label = '打印日志', text = '', color = 'red'):
    print(f'\n----------------{datetime.now()}------------------------')
    print(f'{label}: ')
    if color:
        print(f'\033[31m{text}\033[0m')
    else:
        print(f'{text}')

print_log('tf version', tf.__version__)


# 加载fashion-MNIST 数据集
# train_images 和 train_labels 数组是训练集，即模型用于学习的数据。
# 测试集、test_images 和 test_labels 数组会被用来对模型进行测试。
fasion_mnist = tf.keras.datasets.mnist
(train_images, train_labels), (test_images, test_labels) = fasion_mnist.load_data()

# 服装类-标签
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']

print_log('训练集train_images.shape', train_images.shape)
print_log('训练集标签len(train_labels)', len(train_labels))

print_log('前10个标签: train_labels[:10]', train_labels[:10])

print_log('测试集test_images.shape', test_images.shape)
print_log('测试集标签len(test_labels)', len(test_labels))